package com.yuma.springaialibaba.controller;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class AliDashScopeController {
    @Autowired
    DashScopeChatModel dashScopeChatModel;

    @GetMapping("/ali/call/{msg}")
    public String call(@PathVariable String msg) {
        return dashScopeChatModel.call(msg);
    }

    @GetMapping(value = "/ali/stream/{msg}", produces = "text/html;charset=utf-8")
    public Flux<String> stream(@PathVariable String msg) {
        return dashScopeChatModel.stream(msg);
    }
}
